package com.fanfanwang.ffw.app.ui.login;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.fanfanwang.ffw.app.AppManager;
import com.fanfanwang.ffw.app.tenant.R;
import com.fanfanwang.ffw.app.widget.CommonTitleBar;

/** 注册 */
public class RegisterAct extends com.fanfanwang.ffw.app.base.BaseActivity {

	private CommonTitleBar commonTitleBar;
	private EditText re_et_mobile;
	private Button re_bt_getcode;
	private EditText re_et_code;
	private EditText re_et_password;
	private Button re_btn_complete;
	public String mobile = "";
	public String securityCode = "";
	public String password = "";
	private Activity mAct;
	private Intent mIntent;
	private TextView re_tv_agreement;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		initWidget();
		initData();
		AppManager.getAppManager().addActivity(this);
		widgetClick();
	}

	public void initWidget() {
		setContentView(R.layout.activity_register);
		mAct = this;
		commonTitleBar = (CommonTitleBar) findViewById(R.id.common_titlebar);
		re_et_mobile = (EditText) findViewById(R.id.re_et_mobile);
		re_bt_getcode = (Button) findViewById(R.id.re_bt_getcode);
		re_et_code = (EditText) findViewById(R.id.re_et_code);
		re_et_password = (EditText) findViewById(R.id.re_et_password);
		re_btn_complete = (Button) findViewById(R.id.re_btn_complete);
		re_tv_agreement = (TextView) findViewById(R.id.re_tv_agreement);
	}
	

	public void widgetClick() {
		commonTitleBar.setToolBarReturnOnclickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
		re_tv_agreement.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				mIntent=new Intent(mAct, RegisterAgreementAct.class);
				startActivity(mIntent);
			}
		});
	}

	@Override
	public void initData() {
		commonTitleBar.setCenterText(getString(R.string.register));
		commonTitleBar.setReturnVisible();
	}

	private class MyCount extends CountDownTimer {

		public MyCount(long millisInFuture, long countDownInterval) {
			super(millisInFuture, countDownInterval);
		}

		@Override
		public void onFinish() {
			re_bt_getcode.setText(getString(R.string.register_reget));
			re_bt_getcode.setClickable(true);
		}

		@Override
		public void onTick(long millisUntilFinished) {
			re_bt_getcode.setText("(" + millisUntilFinished / 1000 + ")");
			re_bt_getcode.setClickable(false);
		}

	}

	@Override
	protected void initView() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void setListener() {
		// TODO Auto-generated method stub

	}

}
